package fe.bmsearch.gui.server;

import java.io.IOException;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import fe.bmsearch.gui.client.DocumentItem;
import fe.bmsearch.gui.client.GetDocumentService;
import fe.datatypeUI.HTML;
import fe.datatypeUI.ShortDescription;
import fe.generalmodel.DataType;
import fe.hbasequery.QueryIndex;
import fe.utils.UniqueStringUtils;

public class GetDocumentServiceImpl  extends RemoteServiceServlet implements GetDocumentService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public DocumentItem getDocumentItem(String documentType, String uid) {
		DocumentItem docItem=new DocumentItem("Fejl", "", "");
		try {
			DataType dt=QueryIndex.lookUp(documentType, UniqueStringUtils.hexStringToByteArray(uid));
			docItem=new DocumentItem(ShortDescription.getShortDescription(dt), uid, HTML.getHTML(dt));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NullPointerException e)
		{
			
		}
		return docItem;
	}

}
